<?php
/*
	Project:
		FizzBuzz

	Description:
		Loop through numbers 1-50, if the number is divisible by 3 echo "fizz",
		by 5 echo "buzz", by both 3 & 5 at the same time echo "fizzbuzz",
		otherwise echo out the number.

	Notes:
		I am mixing code and output together for this due to the one-off nature 
		of the request. I know that best Practices would have the 2 separated.
*/

$upToClean = intval($_REQUEST["upTo"]);
$maxLoop = ($upToClean)? $upToClean:50;

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>FizzBuzz</title>
	<style type="text/css">
	.fizz { background: none, #09f; }
	.buzz { background: none, #c6f; }
	.fizzbuzz { background: none, #f06; }
	ol { float: left; }
	</style>
</head>
<body>
	<ol>
<?
echo $maxLoop;

for($i=1; $i<=$maxLoop; $i++){
	$remThree = $i%3; // Remainder from 3
	$remFive = $i%5; // Remainder from 5
	$visOut = '';
	$classOut = '';

	if (!$remThree) {
		$visOut .= 'fizz';
		$classOut .= 'fizz';
	}
	if (!$remFive) {
		$visOut .= 'buzz';
		$classOut .= 'buzz';
	}
	if ($remFive && $remThree) { $visOut = $i; } // class left blank here.

	echo "\t\t<li",($classOut)?" class='{$classOut}'":"",">{$visOut}</li>\n";

}
?>
	</ol>
</body>
</html>